<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>社交活动平台 - 活动类型</title>
    <style>
        /* 重置样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
            background-color: #f5f7fa;
            color: #333;
            line-height: 1.6;
        }

        /* 容器样式 */
        .container {
            max-width: 480px;
            margin: 0 auto;
            background-color: #fff;
            min-height: 100vh;
        }

        /* 头部导航 */
        .header {
            position: sticky;
            top: 0;
            background-color: white;
            padding: 16px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            z-index: 100;
        }

        .header-content {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .back-btn {
            background: none;
            border: none;
            font-size: 24px;
            cursor: pointer;
            color: #333;
        }

        .header-title {
            font-size: 18px;
            font-weight: bold;
            flex-grow: 1;
            text-align: center;
        }

        .action-btn {
            background: none;
            border: none;
            font-size: 20px;
            cursor: pointer;
            color: #333;
        }

        /* 搜索区域 */
        .search-section {
            padding: 16px;
            background-color: #f9f9f9;
            border-bottom: 1px solid #eee;
        }

        .search-container {
            display: flex;
            align-items: center;
            background-color: white;
            border-radius: 24px;
            padding: 8px 16px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        }

        .search-icon {
            color: #999;
            margin-right: 8px;
        }

        .search-input {
            flex-grow: 1;
            border: none;
            outline: none;
            font-size: 15px;
            background-color: transparent;
        }

        /* 活动类型分类 */
        .categories-section {
            padding: 20px 16px;
        }

        .section-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 20px;
        }

        .categories-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 16px;
        }

        .category-card {
            background-color: #f9f9f9;
            border-radius: 16px;
            padding: 20px 12px;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }

        .category-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
        }

        .category-card.selected {
            border-color: #ff6b35;
            background-color: #fff9f0;
        }

        .category-icon {
            font-size: 32px;
            margin-bottom: 12px;
        }

        .category-name {
            font-size: 14px;
            font-weight: bold;
        }

        /* 热门标签 */
        .popular-tags {
            padding: 16px;
        }

        .tags-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 20px;
        }

        .tags-container {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
        }

        .tag {
            background-color: #f0f8ff;
            color: #45b7d1;
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .tag:hover {
            background-color: #e3f2fd;
            transform: scale(1.05);
        }

        .tag.selected {
            background-color: #ff6b35;
            color: white;
        }

        /* 推荐活动 */
        .recommended-section {
            padding: 16px;
        }

        .recommended-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 20px;
        }

        .recommended-list {
            display: flex;
            gap: 16px;
            overflow-x: auto;
            padding-bottom: 16px;
        }

        .recommended-card {
            flex: 0 0 auto;
            width: 140px;
            background-color: #f9f9f9;
            border-radius: 12px;
            overflow: hidden;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .recommended-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
        }

        .recommended-cover {
            width: 100%;
            height: 80px;
            object-fit: cover;
        }

        .recommended-info {
            padding: 12px;
        }

        .recommended-title-small {
            font-size: 14px;
            font-weight: bold;
            margin-bottom: 6px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .recommended-meta {
            display: flex;
            justify-content: space-between;
            font-size: 12px;
            color: #666;
        }

        /* 底部操作按钮 */
        .action-buttons {
            padding: 20px;
            display: flex;
            gap: 16px;
        }

        .action-btn {
            flex: 1;
            padding: 16px;
            border-radius: 24px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s ease;
            border: none;
        }

        .cancel-btn {
            background-color: #f5f5f5;
            color: #666;
        }

        .confirm-btn {
            background: linear-gradient(135deg, #ff6b35 0%, #f9a825 100%);
            color: white;
        }

        .confirm-btn:hover {
            transform: scale(1.02);
            box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
        }

        /* 底部导航 */
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background-color: white;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: space-around;
            padding: 12px 0;
            z-index: 100;
        }

        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: #9e9e9e;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .nav-item.active {
            color: #ff6b35;
        }

        .nav-icon {
            font-size: 20px;
            margin-bottom: 4px;
        }

        /* 加载动画 */
        .loading {
            text-align: center;
            padding: 40px 20px;
        }

        .spinner {
            width: 36px;
            height: 36px;
            border: 4px solid #f3f3f3;
            border-top: 4px solid #ff6b35;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 0 auto 20px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* 弹窗样式 */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            background-color: white;
            border-radius: 16px;
            width: 85%;
            max-width: 320px;
            padding: 24px;
            text-align: center;
            transform: translateY(20px);
            opacity: 0;
            transition: all 0.3s ease;
        }

        .modal.show {
            transform: translateY(0);
            opacity: 1;
        }

        .modal-title {
            font-size: 20px;
            font-weight: bold;
            margin-bottom: 16px;
            color: #333;
        }

        .modal-message {
            margin-bottom: 24px;
            color: #666;
            line-height: 1.6;
        }

        .modal-actions {
            display: flex;
            gap: 12px;
        }

        .modal-btn {
            flex: 1;
            padding: 12px;
            border-radius: 8px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .cancel-btn {
            background-color: #f5f5f5;
            color: #666;
        }

        .confirm-btn {
            background: linear-gradient(135deg, #ff6b35 0%, #f9a825 100%);
            color: white;
        }

        /* 响应式适配 */
        @media (max-width: 480px) {
            .header-content {
                padding-top: 4px;
            }
            
            .categories-grid {
                grid-template-columns: repeat(2, 1fr);
            }
            
            .recommended-card {
                width: 130px;
            }
        }

        /* 动画效果 */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .category-card, .recommended-card {
            animation: fadeInUp 0.6s ease forwards;
        }

        /* 按钮状态动画 */
        .action-btn {
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.02); }
            100% { transform: scale(1); }
        }

        /* 活动类型图标颜色 */
        .icon-sport { color: #1976d2; }
        .icon-learning { color: #7b1fa2; }
        .icon-social { color: #388e3c; }
        .icon-food { color: #f57c00; }
        .icon-culture { color: #c2185b; }
        .icon-outdoor { color: #00796b; }
        .icon-music { color: #ff5722; }
        .icon-art { color: #9c27b0; }
        .icon-tech { color: #45b7d1; }

        /* 空状态 */
        .empty-state {
            text-align: center;
            padding: 60px 20px;
        }

        .empty-icon {
            font-size: 64px;
            margin-bottom: 20px;
            color: #ccc;
        }

        .empty-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 12px;
            color: #666;
        }

        .empty-description {
            color: #999;
            margin-bottom: 24px;
        }

        /* 分类标题 */
        .category-section-title {
            font-size: 16px;
            font-weight: bold;
            margin: 20px 16px 12px;
            color: #333;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 头部导航 -->
        <header class="header">
            <div class="header-content">
                <button class="back-btn" id="backBtn">←</button>
                <div class="header-title">选择活动类型</div>
                <button class="action-btn" id="helpBtn">?</button>
            </div>
        </header>

        <!-- 搜索区域 -->
        <div class="search-section">
            <div class="search-container">
                <span class="search-icon">🔍</span>
                <input type="text" class="search-input" placeholder="搜索活动类型..." id="searchInput">
            </div>
        </div>

        <!-- 活动类型分类 -->
        <div class="categories-section">
            <h2 class="section-title">活动类型</h2>
            
            <!-- 主要分类 -->
            <div class="categories-grid">
                <div class="category-card" data-category="sport">
                    <div class="category-icon icon-sport">🏃</div>
                    <div class="category-name">运动健身</div>
                </div>
                
                <div class="category-card" data-category="learning">
                    <div class="category-icon icon-learning">📚</div>
                    <div class="category-name">学习成长</div>
                </div>
                
                <div class="category-card" data-category="social">
                    <div class="category-icon icon-social">👥</div>
                    <div class="category-name">社交聚会</div>
                </div>
                
                <div class="category-card" data-category="food">
                    <div class="category-icon icon-food">🍕</div>
                    <div class="category-name">美食分享</div>
                </div>
                
                <div class="category-card" data-category="culture">
                    <div class="category-icon icon-culture">🎨</div>
                    <div class="category-name">文化体验</div>
                </div>
                
                <div class="category-card" data-category="outdoor">
                    <div class="category-icon icon-outdoor">🏕️</div>
                    <div class="category-name">户外探险</div>
                </div>
            </div>
        </div>

        <!-- 热门标签 -->
        <div class="popular-tags">
            <h3 class="tags-title">热门标签</h3>
            <div class="tags-container">
                <span class="tag" data-tag="摄影">摄影</span>
                <span class="tag" data-tag="读书">读书</span>
                <span class="tag" data-tag="音乐">音乐</span>
                <span class="tag" data-tag="电影">电影</span>
                <span class="tag" data-tag="手工">手工</span>
                <span class="tag" data-tag="旅行">旅行</span>
                <span class="tag" data-tag="游戏">游戏</span>
                <span class="tag" data-tag="舞蹈">舞蹈</span>
            </div>
        </div>

        <!-- 推荐活动 -->
        <div class="recommended-section">
            <h3 class="recommended-title">为你推荐</h3>
            <div class="recommended-list">
                <div class="recommended-card" data-activity="1">
                    <img src="https://images.unsplash.com/photo-1501854140801-50d01698950b?w=200&h=80&fit=crop" alt="户外徒步" class="recommended-cover">
                    <div class="recommended-info">
                        <div class="recommended-title-small">周末户外徒步</div>
                        <div class="recommended-meta">
                            <span>运动</span>
                            <span>12人参与</span>
                        </div>
                    </div>
                </div>
                
                <div class="recommended-card" data-activity="2">
                    <img src="https://images.unsplash.com/photo-1504805572947-34fad45aed93?w=200&h=80&fit=crop" alt="读书分享" class="recommended-cover">
                    <div class="recommended-info">
                        <div class="recommended-title-small">经典小说读书会</div>
                        <div class="recommended-meta">
                            <span>学习</span>
                            <span>8人参与</span>
                        </div>
                    </div>
                </div>
                
                <div class="recommended-card" data-activity="3">
                    <img src="https://images.unsplash.com/photo-1543269865-cbf427effbad?w=200&h=80&fit=crop" alt="摄影交流" class="recommended-cover">
                    <div class="recommended-info">
                        <div class="recommended-title-small">摄影技巧交流会</div>
                        <div class="recommended-meta">
                            <span>文化</span>
                            <span>15人参与</span>
                        </div>
                    </div>
                </div>
                
                <div class="recommended-card" data-activity="4">
                    <img src="https://images.unsplash.com/photo-1503376780353-7e6692767b70?w=200&h=80&fit=crop" alt="美食探店" class="recommended-cover">
                    <div class="recommended-info">
                        <div class="recommended-title-small">城市美食探店</div>
                        <div class="recommended-meta">
                            <span>美食</span>
                            <span>20人参与</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 底部操作按钮 -->
        <div class="action-buttons">
            <button class="action-btn cancel-btn" id="cancelBtn">取消</button>
            <button class="action-btn confirm-btn" id="confirmBtn">确定选择</button>
        </div>

        <!-- 底部导航 -->
        <nav class="bottom-nav">
            <div class="nav-item" data-page="home">
                <span class="nav-icon">🏠</span>
                <span>首页</span>
            </div>
            <div class="nav-item" data-page="search">
                <span class="nav-icon">🔍</span>
                <span>搜索</span>
            </div>
            <div class="nav-item" data-page="publish">
                <span class="nav-icon">➕</span>
                <span>发布</span>
            </div>
            <div class="nav-item active" data-page="profile">
                <span class="nav-icon">👤</span>
                <span>我的</span>
            </div>
        </nav>

        <!-- 帮助弹窗 -->
        <div class="modal" id="helpModal">
            <div class="modal-content">
                <h3 class="modal-title">活动类型说明</h3>
                <p class="modal-message">
                    选择合适的活动类型有助于精准推荐和匹配：<br><br>
                    • 运动健身：户外运动、室内健身等<br>
                    • 学习成长：读书会、技能分享等<br>
                    • 社交聚会：朋友聚餐、主题派对等<br>
                    • 美食分享：探店体验、烹饪交流等<br>
                    • 文化体验：展览参观、手工制作等
                </p>
                <div class="modal-actions">
                    <button class="modal-btn cancel-btn" id="closeHelpBtn">知道了</button>
                </div>
            </div>
        </div>

        <!-- 加载状态 -->
        <div class="loading" id="loadingIndicator">
            <div class="spinner"></div>
            <p>加载中...</p>
        </div>

        <!-- 通知 Toast -->
        <div id="toast" style="display: none; position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background-color: #4caf50; color: white; padding: 12px 24px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 1001;"></div>
    </div>

    <script>
        // 全局变量
        let selectedCategories = [];
        let selectedTags = [];
        let recommendedActivities = [];

        // 初始化
        document.addEventListener('DOMContentLoaded', function() {
            initEventListeners();
            simulateLoading();
            
            // 模拟加载数据
            setTimeout(() => {
                updateSelectionDisplay();
            }, 1000);
        });

        // 初始化事件监听器
        function initEventListeners() {
            // 返回按钮
            document.getElementById('backBtn').addEventListener('click', function() {
                window.history.back();
            });

            // 帮助按钮
            document.getElementById('helpBtn').addEventListener('click', function() {
                const modal = document.getElementById('helpModal');
                modal.classList.add('show');
            });

            // 关闭帮助弹窗
            document.getElementById('closeHelpBtn').addEventListener('click', function() {
                const modal = document.getElementById('helpModal');
                modal.classList.remove('show');
            });

            // 帮助弹窗背景点击关闭
            document.getElementById('helpModal').addEventListener('click', function(e) {
                if (e.target === this) {
                    this.classList.remove('show');
                }
            });

            // 底部导航切换
            const navItems = document.querySelectorAll('.nav-item');
            navItems.forEach(item => {
                item.addEventListener('click', function() {
                    // 移除所有激活状态
                    navItems.forEach(i => i.classList.remove('active'));
                    // 添加当前激活状态
                    this.classList.add('active');
                    
                    const page = this.dataset.page;
                    handleNavigation(page);
                });
            });

            // 活动类型卡片点击
            const categoryCards = document.querySelectorAll('.category-card');
            categoryCards.forEach(card => {
                card.addEventListener('click', function() {
                    const categoryId = this.dataset.category;
                    toggleCategorySelection(categoryId);
                });
            });

            // 标签点击
            const tagElements = document.querySelectorAll('.tag');
            tagElements.forEach(tag => {
                tag.addEventListener('click', function() {
                    const tagName = this.dataset.tag;
                    toggleTagSelection(tagName);
                });
            });

            // 推荐活动点击
            const recommendedCards = document.querySelectorAll('.recommended-card');
            recommendedCards.forEach(card => {
                card.addEventListener('click', function() {
                    const activityId = this.dataset.activity;
                    handleRecommendedActivityClick(activityId);
                });
            });

            // 搜索功能
            const searchInput = document.getElementById('searchInput');
            searchInput.addEventListener('input', function() {
                const searchTerm = this.value.toLowerCase();
                filterCategories(searchTerm);
            });

            // 确定按钮
            document.getElementById('confirmBtn').addEventListener('click', function() {
                if (selectedCategories.length === 0 && selectedTags.length === 0) {
                    showSuccessToast('请至少选择一个活动类型或标签');
                    return;
                }
                
                const selectedText = selectedCategories.length > 0 ? 
                    `已选择活动类型: ${selectedCategories.join(', ')}` : 
                    '已选择标签';
                
                showSuccessToast(`活动类型设置成功！${selectedText}`);
                
                // 模拟跳转到发布页面
                setTimeout(() => {
                    alert('跳转到活动发布页面');
                }, 1000);
            });

            // 取消按钮
            document.getElementById('cancelBtn').addEventListener('click', function() {
                if (confirm('确定要取消选择吗？')) {
                    // 清空选择
                    selectedCategories = [];
                    selectedTags = [];
                    updateSelectionDisplay();
                    showSuccessToast('已取消选择');
                }
            });

            // 模拟数据更新
            setInterval(() => {
                updateSelectionDisplay();
            }, 60000); // 每分钟更新一次
        }

        // 切换活动类型选择
        function toggleCategorySelection(categoryId) {
            const card = document.querySelector(`[data-category="${categoryId}"]`);
            
            if (selectedCategories.includes(categoryId)) {
                // 取消选择
                selectedCategories = selectedCategories.filter(id => id !== categoryId);
                card.classList.remove('selected');
            } else {
                // 添加选择
                selectedCategories.push(categoryId);
                card.classList.add('selected');
            }
            
            updateSelectionDisplay();
        }

        // 切换标签选择
        function toggleTagSelection(tagName) {
            const tagElement = document.querySelector(`[data-tag="${tagName}"]`);
            
            if (selectedTags.includes(tagName)) {
                // 取消选择
                selectedTags = selectedTags.filter(tag => tag !== tagName);
                tagElement.classList.remove('selected');
            } else {
                // 添加选择
                selectedTags.push(tagName);
                tagElement.classList.add('selected');
            }
            
            updateSelectionDisplay();
        }

        // 更新选择显示
        function updateSelectionDisplay() {
            const selectedText = document.getElementById('selectedText');
            
            if (selectedCategories.length > 0 || selectedTags.length > 0) {
                let displayText = '';
                if (selectedCategories.length > 0) {
                    const categoryNames = selectedCategories.map(cat => getCategoryName(cat));
                    displayText += `活动类型: ${categoryNames.join(', ')}`;
                }
                
                if (selectedTags.length > 0) {
                    displayText += selectedCategories.length > 0 ? ` | 标签: ${selectedTags.join(', ')}` : `标签: ${selectedTags.join(', ')}`;
                }
                
                if (selectedText) {
                    selectedText.textContent = displayText;
                }
            } else {
                if (selectedText) {
                    selectedText.textContent = '暂无选择';
                }
            }
        }

        // 获取活动类型名称
        function getCategoryName(categoryId) {
            const categoryMap = {
                'sport': '运动健身',
                'learning': '学习成长',
                'social': '社交聚会',
                'food': '美食分享',
                'culture': '文化体验',
                'outdoor': '户外探险'
            };
            return categoryMap[categoryId] || categoryId;
        }

        // 处理推荐活动点击
        function handleRecommendedActivityClick(activityId) {
            const activity = getRecommendedActivityById(activityId);
            alert(`查看推荐活动详情：${activity.title}`);
        }

        // 获取推荐活动信息
        function getRecommendedActivityById(id) {
            const activities = [
                { id: '1', title: '周末户外徒步', category: 'sport' },
                { id: '2', title: '经典小说读书会', category: 'learning' },
                { id: '3', title: '摄影技巧交流会', category: 'culture' },
                { id: '4', title: '城市美食探店', category: 'food' }
            ];
            
            return activities.find(activity => activity.id === id) || { title: '未知活动' };
        }

        // 过滤分类
        function filterCategories(searchTerm) {
            const categoryCards = document.querySelectorAll('.category-card');
            
            categoryCards.forEach(card => {
                const categoryName = card.querySelector('.category-name').textContent.toLowerCase();
                
                if (searchTerm === '' || categoryName.includes(searchTerm)) {
                    card.style.display = 'block';
                } else {
                    card.style.display = 'none';
                }
            });
        }

        // 处理导航切换
        function handleNavigation(page) {
            switch(page) {
                case 'home':
                    alert('跳转到首页');
                    break;
                case 'search':
                    alert('跳转到搜索页面');
                    break;
                case 'publish':
                    alert('跳转到发布页面');
                    break;
                case 'profile':
                    // 个人中心无需特殊处理
                    break;
            }
        }

        // 显示加载状态
        function showLoading() {
            const loading = document.getElementById('loadingIndicator');
            loading.style.display = 'block';
        }

        // 隐藏加载状态
        function hideLoading() {
            const loading = document.getElementById('loadingIndicator');
            loading.style.display = 'none';
        }

        // 模拟加载效果
        function simulateLoading() {
            showLoading();
            setTimeout(() => {
                hideLoading();
            }, 1500);
        }

        // 显示成功提示
        function showSuccessToast(message) {
            const toast = document.getElementById('toast');
            toast.textContent = message;
            toast.style.display = 'block';
            
            // 3秒后自动隐藏
            setTimeout(() => {
                toast.style.display = 'none';
            }, 3000);
        }

        // 添加触摸反馈效果
        const buttons = document.querySelectorAll('button, .category-card, .tag, .recommended-card');
        buttons.forEach(button => {
            button.addEventListener('touchstart', function() {
                this.style.transform = 'scale(0.95)';
            });
            
            button.addEventListener('touchend', function() {
                this.style.transform = 'scale(1)';
            });
        });

        // 添加页面滚动效果
        let lastScrollTop = 0;
        window.addEventListener('scroll', function() {
            const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
            
            // 隐藏/显示底部导航
            const bottomNav = document.querySelector('.bottom-nav');
            if (scrollTop > lastScrollTop && scrollTop > 100) {
                bottomNav.style.transform = 'translateY(100%)';
            } else {
                bottomNav.style.transform = 'translateY(0)';
            }
            
            lastScrollTop = scrollTop;
        });

        // 添加返回顶部功能
        window.addEventListener('scroll', function() {
            if (window.pageYOffset > 300) {
                // 可以添加返回顶部按钮
            }
        });
    </script>
</body>
</html>
